package TUILayer;
import java.util.Scanner;
import ControlLayer.*;

/**
 * The main user interface for the program.
 * 
 * @author (Gruppe 3)
 */
public class MainUI
{
    // instance variables
    private PersonUI personUI;
    private SaleUI saleUI;
    private StorageUI storageUI;

    /**
     * Constructor for objects of class MainUI
     */
    public MainUI()
    {
    
    }
    
    /**
     * Starts the menu
     */
    public void mainMenuStart()
    {
        boolean close=false;
        while(!close)
        {
            int choice = makeMainMenu();
            if(choice == 1)
            {
                //open Person menu
                openPersonUI();
            }
            else
            {
                if(choice == 2)
                {
                    //open Sale menu
                    openSaleUI();
                }
                else
                {
                    if(choice == 3)
                    {
                        //open Storage menu
                        openStorageUI();
                    }
                    else
                    {
                        if(choice == 4)
                        {
                            closeProgram();
                            close = true;
                    }
                    else
                    {
                        System.out.println("Indtast et nr. mellem 1 og 4");
                    }
                }
            }
         }
      }
    }
    
    /**
     * Prints the main menu
     */
    private int makeMainMenu()
    {
        Scanner keyboard = new Scanner(System.in); 
        System.out.println("\f ### Main Menu ### ");
        System.out.println(" (1) Person menu");
        System.out.println(" (2) Salgs menu");
        System.out.println(" (3) Lager menu");
        System.out.println(" (4) Luk");
        System.out.println("\n Vælg et nummer: ");
        
        int choice = keyboard.nextInt();
        return choice;
    }
    
    /**
     * Opens the person menu
     */ 
    private void openPersonUI()
    {
        personUI = new PersonUI();
        personUI.open();
    }
    
    /**
     * Opens the sale menu
     */ 
    private void openSaleUI()
    {
        saleUI = new SaleUI();
        saleUI.open();
    }
    
    /**
     * Opens the storage menu
     */ 
    private void openStorageUI()
    {
        storageUI = new StorageUI();
        storageUI.open();
    }
    
    /**
     * Quits the program
     */ 
    private void closeProgram()
    {
        System.out.println("Programmet lukkes ");
    }
    
}
